package com.fh.gs.config;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import com.netflix.loadbalancer.RoundRobinRule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @FileName : MyCustomRule
 * @Description :
 * @Author : fh
 * @Date : 2020/11/18 10:56
 * @Version : 1.0.0
 */
@Configuration
public class MyCustomRule {

    /**
     * 初始化负载均衡策略
     * @return
     */
    @Bean
    public IRule iRule(){
        //七种负载均衡规则 选择随机算法
        //return new RandomRule();
        //选择轮询算法
        //return new RoundRobinRule();
        return new MyRandomRule();
    }
}
